import java.util.Scanner;

// 基类
class Person1 {
    int number;

    Person1(int number) {
        this.number = number;
    }

    // 虚方法
    public void welcome() {
        System.out.println("Welcome, generic person with number: " + number);
    }
}

// Enemy类，继承自Person类
class Enemy extends Person1 {
    Enemy(int number) {
        super(number);
    }

    // 重写welcome方法
    @Override
    public void welcome() {
        System.out.println("Enemy detected with number: " + number + ". Preparing the hunt!");
    }
}

// Friend类，继承自Person类
class Friend extends Person1 {
    Friend(int number) {
        super(number);
    }

    // 重写welcome方法  
    @Override
    public void welcome() {
        System.out.println("Friend arrived with number: " + number + ". Offering a good drink!");
    }
}

public class Main {
    public static void main(String[] args) {
        // 用于存放Person对象的数组
        Person1[] people = new Person1[10]; // 假设最多有10个对象
        int index = 0;

        // 从控制台读取整数，并根据规则创建对象
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter integers (enter a negative number to stop):");
        while (scanner.hasNextInt() && index < people.length) {
            int num = scanner.nextInt();

            Person1 person;
            if (num % 3 == 0) {
                person = new Person1(num);
            } else if (num % 3 == 1) {
                person = new Enemy(num);
            } else {
                person = new Friend(num);
            }

            people[index++] = person;
        }

        // 关闭Scanner
        scanner.close();

        // 遍历数组并执行welcome方法
        for (int i = 0; i < index; i++) {
            people[i].welcome();
        }
    }
}